<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v-bind="http://www.w3.org/1999/xhtml">

<head>
    <title>管理员管理</title>
    <link href="/js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="/js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="/css/table.css" rel="stylesheet" type="text/css">

    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
</head>
<body style="background-color: #ecf0f5;font-family: 微软雅黑;color: #475059;min-width: 1000px;overflow: auto">
<div id="app" >
    <div class="notice_main">
        <table id="table" class="table_style" style="margin: 0 auto" > </table>
    </div>
    <script src="js/jquery/jQuery-2.2.0.min.js"></script>
    <script src="js/bstable/js/bootstrap.min.js"></script>
    <script src="js/bstable/js/bootstrap-table.js"></script>
    <script src="js/bstable/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="js/layer_v2.1/layer/layer.js"></script>

    <form method="post" enctype="multipart/form-data"  class="form-horizontal">
        <div class="alert alert-danger" role="alert">
            <p>修改管理员</p>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">管理员姓名</label>
            <div class="col-sm-8">
                <input type="text" v-model="admin.admin_name" name="title"  class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">管理员密码</label>
            <div class="col-sm-8">
                <input type="text" v-model="admin.admin_pass" name="comtent"  class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">分组</label>
            <div class="col-sm-8">
                <select  v-model="admin.admin_group" class="form-control" name="stu_education">
                    <option value="前端">前端</option>
                    <option value="后台">后台</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">管理员注册日期</label>
            <div class="col-sm-8">
                <input type="date" v-model="admin.admin_date" name="comtent"  class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">创建日期</label>
            <div class="col-sm-8">
                <input type="date" v-model="admin.create_date" name="release_time" class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button"  @click="updateAdmin" class="btn btn-info">修改管理员</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>

<script>
    new Vue({
        el:"#app",
        data:{
            admin:{
            }
        },
        methods:{
            updateAdmin:function(){
                console.log(this.admin)
                axios.post('/admin/update', this.admin)
                    .then(function (response) {
                        console.log(response.data);
                        if(response.data==1){
                            alert("修改成功！")
                            location.href="admin.html"
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        },
    mounted(){
        var _this = this
        var admin_id = window.localStorage.getItem("sid")
        console.log("主键为："+ admin_id)
        axios.get('/admin/update',{
            params:{
                admin_id: admin_id
            }
        })
            .then(function (response){
                _this.admin = response.data
                console.log(response.data);
            })
            .catch(function (error){
                console.log(error);
            });

            // _this = this
            // axios.get('/admin/list')
            //     .then(function (response){
            //         _this.admininfo = response.data
            //         console.log(_this.admininfo);
            //     })
            //     .catch(function (error){
            //         console.log(error);
            //     });
        },
    })
</script>